package com.villaday.idf.activity;

import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import androidx.appcompat.widget.Toolbar;

import android.view.View;
import android.widget.ImageButton;

import com.villaday.idf.R;
import com.villaday.idf.base.BaseActivity;
import com.villaday.idf.fragment.GoodsFragment;
import com.villaday.idf.fragment.SVIPLibaoFragment;
import com.villaday.idf.fragment.SvipFreeFragment;
import com.villaday.idf.util.TabLayoutUtils;

import butterknife.BindView;
import butterknife.OnClick;

/*
 * 礼包邀请 免费邀请
 * */
public class SVIPLibaoAndFreeActivity extends BaseActivity {

    @BindView(R.id.toolbar_iconBack)
    ImageButton toolbarIconBack;
    @BindView(R.id.tab)
    TabLayout tab;
    @BindView(R.id.toolbar_iconNext)
    ImageButton toolbarIconNext;
    @BindView(R.id.vp)
    ViewPager vp;
    @BindView(R.id.toolbar_icon)
    Toolbar toolbarIcon;
    private GoodsFragment instance;


    @Override
    protected int getViewResId() {
        return R.layout.activity_svip_libao_free;
    }

    @Override
    protected void init() {

//右边图标
        toolbarIconNext.setVisibility(View.GONE);
        toolbarIconNext.setImageResource(R.drawable.detailspage_share);
        final String[] titles;


            titles = new String[]{"礼包邀请", "免费邀请"};



        //instance.setChangePage(this);
        vp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return position==0? SVIPLibaoFragment.instance(): SvipFreeFragment.instance() ;
            }

            @Override
            public int getCount() {
                return titles.length;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return titles[position];
            }
        });
        tab.setupWithViewPager(vp);
        vp.setCurrentItem(getIntent().getIntExtra("type",0));
        TabLayoutUtils.reflex(tab, 19);


    }


    @OnClick({R.id.toolbar_iconBack, R.id.toolbar_iconNext})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.toolbar_iconBack: {//返回
                onBackPressed();
            }
            break;
            case R.id.toolbar_iconNext: {//右边图标
                if (instance != null) {
                    instance.shareXCX();
                }


            }
            break;
        }
    }


   /* @Override
    public void changePage() {
        vp.setCurrentItem(1);
    }*/

    /*@Override
    public void onBackPressed() {
        if (!BackHandlerHelper.handleBackPress(this)) {
            super.onBackPressed();
        }
    }*/

}
